package com.itheima.mp.controller;

import com.itheima.mp.domain.ResponseResult;
import com.itheima.mp.domain.dto.LoginUserDto;
import com.itheima.mp.service.ILoginService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
public class LoginController {

    private final ILoginService loginService;
    @PostMapping("/user/login")
    public ResponseResult login(@RequestBody LoginUserDto loginUser) {

        return loginService.login(loginUser);
    }


    @GetMapping("/user/logout")
    public ResponseResult logout() {
        return loginService.logout();
    }

    @PreAuthorize("hasAuthority('menu:view')")
    @GetMapping("/hello")
    public String hello() {
        return "hello";
    }
}
